const canvas = document.querySelector("#canvas");
const context = canvas.getContext("2d");

const BOMB_LEFT = 220;
const BOMB_TOP = 80;
const BOMB_WIDTH = 180;
const BOMB_HEIGHT = 130;

function ImagePainter(imageUrl) {
    this.image = new Image();
    this.image.src = imageUrl;
}
ImagePainter.prototype = {
    paint(sprite, context) {
        if (this.image.complete) {
            context.drawImage(
                this.image,
                sprite.left,
                sprite.top,
                sprite.width,
                sprite.height
            );
        }
    }
};
const bomb = new Sprite("bomb", new ImagePainter("bomb.png"));

function animate() {
    context.clearRect(0, 0, canvas.width, canvas.height);
    bomb.paint(context);
    requestAnimationFrame(animate);
}

bomb.left = BOMB_LEFT;
bomb.top = BOMB_TOP;
bomb.width = BOMB_WIDTH;
bomb.height = BOMB_HEIGHT;

requestAnimationFrame(animate);
